package com.wh.hotel.model;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.wh.hotel.vo.PayWayRuleVo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * <p>
 * 酒店房型商品表
 * </p>
 *
 * @author 
 * @since 2023-05-03
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("hotel_room_type_goods")
public class HotelRoomTypeGoods extends Model<HotelRoomTypeGoods> {

    private static final long serialVersionUID=1L;

    /**
     * 房型商品ID
     */
      @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 创建时间
     */
    private Date createDt;

    /**
     * 更新时间
     */
    private Date updateDt;

    /**
     * 房型id
     */
    private Long roomTypeId;

    /**
     * 支付方式，0=预付 1=现付
     */
    private Integer payWay;

    /**
     * 早餐数量
     */
    private Integer breakfastNum;

    /**
     * 担保类型
     */
    private Integer guaranteeType;

    /**
     * 取消类型
     */
    private Integer cancelType;

    /**
     * 取消扣款规则json
     */
    private String cancelRule;

    /**
     * 商品状态, 1=正常，2=下架
     */
    private Integer goodsStatus;


    public static final String ID = "id";

    public static final String CREATE_DT = "create_dt";

    public static final String UPDATE_DT = "update_dt";

    public static final String ROOM_TYPE_ID = "room_type_id";

    public static final String PAY_WAY = "pay_way";

    public static final String BREAKFAST_NUM = "breakfast_num";

    public static final String GUARANTEE_TYPE = "guarantee_type";

    public static final String CANCEL_TYPE = "cancel_type";

    public static final String CANCEL_RULE = "cancel_rule";

    public static final String GOODS_STATUS = "goods_status";

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        HotelRoomTypeGoods that = (HotelRoomTypeGoods) o;
        PayWayRuleVo thisPatWay = JSONUtil.toBean(cancelRule, PayWayRuleVo.class);
        PayWayRuleVo thatPatWay = JSONUtil.toBean(that.cancelRule, PayWayRuleVo.class);

        return Objects.equals(roomTypeId, that.roomTypeId) && Objects.equals(payWay, that.payWay)
                && Objects.equals(breakfastNum, that.breakfastNum) && Objects.equals(guaranteeType, that.guaranteeType)
                && Objects.equals(cancelType, that.cancelType)
                && Objects.equals(thisPatWay.getFirstNightMinuteForStart(), thatPatWay.getFirstNightMinuteForStart())
                && Objects.equals(thisPatWay.getFreeCancelMinuteForStart(), thatPatWay.getFreeCancelMinuteForStart())
                ;
    }

    @Override
    public int hashCode() {
        PayWayRuleVo thisPatWay = JSONUtil.toBean(cancelRule, PayWayRuleVo.class);
        return Objects.hash(roomTypeId, payWay, breakfastNum, guaranteeType, cancelType,
                thisPatWay.getFirstNightMinuteForStart(), thisPatWay.getFreeCancelMinuteForStart());
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

}
